<template>
	<view class="factory-profile-page">
		<!-- 顶部导航栏复用 -->
		<TopBar
			left-icon="/static/user.png"
			scan-icon="/static/saoyisao.png"
			menu-icon="/static/menu.png"
			@menu="toggleMenu"
		/>

		<scroll-view scroll-y class="form-scroll">
			<!-- 返回箭头独立一行 -->
			<view class="back-row" @click="goBack">
				<image class="back-arrow-icon" src="/static/left.png" mode="aspectFit" />
			</view>

			<!-- 标题 -->
			<view class="header">
				<text class="title">Factory Profile</text>
				<text class="subtitle">Section 3. Commercial positioning</text>
			</view>

			<!-- Upload photo -->
			<text class="section-label">Upload a representative product photo</text>
			<view class="input with-icon">
				<image src="/static/paperclip.png" class="clip" mode="aspectFit" />
				<input v-model="productPhoto" placeholder="" />
			</view>

			<!-- Apparel types -->
			<text class="section-label mt24">Apparel types</text>
			<view class="list">
				<view class="row item" v-for="it in apparelTypes" :key="it.key" @click="it.checked = !it.checked">
					<view class="checkbox" :class="{ checked: it.checked }"><text class="checkmark" v-if="it.checked">✓</text></view>
					<text class="item-text">{{ it.label }}</text>
					<image src="/static/paperclip.png" class="row-icon" mode="aspectFit" />
				</view>
			</view>

			<!-- Quality level -->
			<text class="section-label mt24">Quality level</text>
			<view class="list">
				<view class="row item" v-for="it in qualityLevels" :key="it.key" @click="it.checked = !it.checked">
					<view class="checkbox" :class="{ checked: it.checked }"><text class="checkmark" v-if="it.checked">✓</text></view>
					<text class="item-text">{{ it.label }}</text>
				</view>
			</view>

			<!-- Brand examples -->
			<text class="section-label mt24">Brand examples (optional, max 3):</text>
			<view class="input">
				<input v-model="brandExamples" placeholder="" />
			</view>

			<!-- Design freedom -->
			<text class="section-label mt24">Design freedom</text>
			<view class="list">
				<view class="row item" v-for="it in designFreedom" :key="it.key" @click="it.checked = !it.checked">
					<view class="checkbox" :class="{ checked: it.checked }"><text class="checkmark" v-if="it.checked">✓</text></view>
					<text class="item-text">{{ it.label }}</text>
				</view>
			</view>

			<!-- Public catalogue -->
			<text class="section-label mt24">Public catalogue (PDF, max 5MB)</text>
			<text class="hint">visible to everyone on factory card</text>
			<view class="input with-icon">
				<image src="/static/paperclip.png" class="clip" mode="aspectFit" />
				<input v-model="publicCatalogue" placeholder="" />
			</view>

			<!-- Private catalogue -->
			<text class="section-label mt24">Private catalogue (PDF, max 10MB)</text>
			<text class="hint">visible visible after approval from the factory</text>
			<view class="input with-icon">
				<image src="/static/paperclip.png" class="clip" mode="aspectFit" />
				<input v-model="privateCatalogue" placeholder="" />
			</view>

			<!-- Terms -->
			<view class="row terms" @click="acceptTerms = !acceptTerms">
				<view class="checkbox" :class="{ checked: acceptTerms }"><text class="checkmark" v-if="acceptTerms">✓</text></view>
				<text class="item-text terms-text">I accept the terms</text>
			</view>
			<text class="link">Read our T&Cs</text>

			<button class="save-btn" @click="save">Save information</button>
		</scroll-view>

		<AccountMenu
			v-if="showMenu"
			:style="{ '--anchor-top': '70px', '--anchor-right': '16px' }"
			@close="closeMenu"
			@select="closeMenu"
		/>
	</view>
</template>

<script setup>
import { ref } from 'vue';
import TopBar from '@/components/TopBar.vue';
import AccountMenu from '@/components/AccountMenu.vue';

const showMenu = ref(false);
const toggleMenu = () => { showMenu.value = !showMenu.value; };
const closeMenu = () => { showMenu.value = false; };

const goBack = () => {
	uni.navigateBack();
};

const productPhoto = ref('');
const apparelTypes = ref([
	{ key: 'w', label: 'Womenswear', checked: false },
	{ key: 'm', label: 'Menswear', checked: false },
	{ key: 'u', label: 'Unisex', checked: false },
	{ key: 's', label: 'Sportswear', checked: false },
	{ key: 'k', label: 'Kidswear', checked: false }
]);
const qualityLevels = ref([
	{ key: 'lux', label: 'Luxury (retail price > €1000)', checked: true },
	{ key: 'pre', label: 'Premium (retail price €300–1000)', checked: true },
	{ key: 'mid', label: 'Mid-market (retail price €50–300)', checked: false },
	{ key: 'fast', label: 'Fast Fashion (retail price < €50)', checked: false }
]);
const brandExamples = ref('');
const designFreedom = ref([
	{ key: 'oem', label: 'OEM — produce based on brand’s design', checked: true },
	{ key: 'odm', label: 'ODM — offer own styles/patterns for brands to adapt', checked: true },
	{ key: 'co', label: 'Co-creation — develop new designs together with brand', checked: false }
]);
const publicCatalogue = ref('');
const privateCatalogue = ref('');
const acceptTerms = ref(false);

const save = () => {
	uni.reLaunch({ url: '/pages/person/person' });
};
</script>

<style lang="scss">
.factory-profile-page { min-height: 100vh; background: linear-gradient(to bottom, #BFE7FF 0%, #EBFFE8 86%, #FFFFFF 100%); }
.form-scroll { margin-top: 60px; padding: 0 16px 40px 16px; box-sizing: border-box; }
.back-row { margin: 12px 0; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
.back-arrow-icon { width: 32px; height: 32px; }
.header { margin-bottom: 8px; }
.title { font-size: 22px; font-weight: 800; color: #0b1e2a; }
.subtitle { display: block; margin-top: 6px; color: #3b5560; font-size: 14px; }

.section-label { display: block; margin: 16px 0 8px 0; color: #23323a; font-size: 14px; font-weight: 700; }
.mt24 { margin-top: 24px; }
.input { height: 44px; background: #fff; border-radius: 10px; display: flex; align-items: center; padding: 0 12px; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.input.with-icon { position: relative; padding-left: 36px; }
.input input { flex: 1; height: 100%; border: none; outline: none; font-size: 14px; color: #333; }
.clip { position: absolute; left: 10px; width: 18px; height: 18px; opacity: .8; }

.list { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; }
.item { background: transparent; }
.checkbox { width: 18px; height: 18px; border: 2px solid #222; border-radius: 4px; margin-right: 10px; display: flex; align-items: center; justify-content: center; background: #fff; }
.checkbox.checked { background: #000; border-color: #000; }
.checkmark { color: #fff; font-size: 12px; font-weight: 700; }
.item-text { color: #0b1e2a; font-size: 14px; }
.row-icon { width: 16px; height: 16px; margin-left: auto; opacity: .8; }

.hint { color: #97a4ad; font-size: 12px; margin: 4px 0 8px; display: block; }
.terms { margin-top: 20px; }
.terms-text { text-align: left; }
.link { color: #6b7f8a; font-size: 12px; text-decoration: underline; margin: 6px 0 16px; display: block; margin-left: 28px; text-align: left; }

.save-btn { margin: 0 8px 24px; height: 44px; background: #222; color: #fff; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
</style>


